package game.module.mail.bean;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;

import game.module.item.bean.GainItemBean;
import game.util.StrKit;

/**
 * @author: Pomelo.Lee
 * @date: 2017年8月24日 上午11:44:26
 */
public class HallMailBean {

	private static Logger logger = LoggerFactory.getLogger(HallMailBean.class);

	private Long id;
	private Integer playerId;
	private Integer templateId;
	private Integer sendPlayerId; // 0.为系统 默认小于10都为系统
	private String sendName;
	private String mailTitle;
	private String mailContent;
	private String mailAttach;
	private Date createTime;
	private Integer isRead; // 0.未读 1.已读未领取 2.已完成（已读且领取）
	private String otherMsg; // 其他配置信息

	private Integer delFlag; // 0.默认 1.删除标记

	private List<GainItemBean> attachList = null;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Integer getPlayerId() {
		return playerId;
	}

	public void setPlayerId(Integer playerId) {
		this.playerId = playerId;
	}

	public Integer getTemplateId() {
		return templateId;
	}

	public void setTemplateId(Integer templateId) {
		this.templateId = templateId;
	}

	public Integer getSendPlayerId() {
		return sendPlayerId;
	}

	public void setSendPlayerId(Integer sendPlayerId) {
		this.sendPlayerId = sendPlayerId;
	}

	public String getSendName() {
		return sendName;
	}

	public void setSendName(String sendName) {
		this.sendName = sendName;
	}

	public String getMailTitle() {
		return mailTitle;
	}

	public void setMailTitle(String mailTitle) {
		this.mailTitle = mailTitle;
	}

	public String getMailContent() {
		return mailContent;
	}

	public void setMailContent(String mailContent) {
		this.mailContent = mailContent;
	}

	public String getMailAttach() {
		return mailAttach;
	}

	public void setMailAttach(String mailAttach) {
		this.mailAttach = mailAttach;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Integer getIsRead() {
		return isRead;
	}

	public void setIsRead(Integer isRead) {
		this.isRead = isRead;
	}

	public Integer getDelFlag() {
		return delFlag;
	}

	public void setDelFlag(Integer delFlag) {
		this.delFlag = delFlag;
	}

	public List<GainItemBean> getAttachList() {
		if (this.attachList != null) {
			return this.attachList;
		}
		if (StrKit.isEmpty(this.mailAttach)) {
			this.attachList = new ArrayList<>();
			return this.attachList;
		}
		List<GainItemBean> listAttach = null;
		ObjectMapper mapper = new ObjectMapper();
		try {
			listAttach = mapper.readValue(this.mailAttach, new TypeReference<List<GainItemBean>>() {
			});
		} catch (Exception e) {
			logger.error(" json maill attach error maillAttach={}:", this.mailAttach);
		}
		this.attachList = listAttach == null ? new ArrayList<>() : listAttach;
		return this.attachList;
	}

	public String getOtherMsg() {
		return otherMsg;
	}

	public void setOtherMsg(String otherMsg) {
		this.otherMsg = otherMsg;
	}
	
}
